Buret = Widget.extend({
	runningAction:null,
	ctor:function(){
		this._super();
		this.init();
		this.setTag(TAG_BURET_ALL);
	},
	init:function(){
		this.body = new Button(this, 10, TAG_BURET, "#Buret.png", this.callback,this);
		this.body.setAnchorPoint(cc.p(0.5, 0.8));
		
		var film=new Button(this.body,10,TAG_FILM2,"#film.png",this.callback,this);
		film.setPosition(cc.p(this.body.width*0.4,this.body.height*0.185));
		film.setScale(0.15);
		film.setOpacity(0);
		
		var open_close=new Button(this.body,10,TAG_OPEN,"#open.png",this.callback,this);
		open_close.setPosition(cc.p(this.body.width*0.5, this.body.height*0.11));
		open_close.setScale(1.1);
		
	},
	show:function(){
		var show1=new Button(this.body,10,TAG_SHOW5,"#show6.png",this.callback,this); 
		show1.setPosition(cc.p(this.body.width*2.5,this.body.height*0.75));
		show1.setOpacity(0);
		var fadein=cc.fadeIn(0.1);
		var fadeout=cc.fadeOut(0.1);
		show1.runAction(cc.sequence(fadein,cc.delayTime(1),fadeout));
	},
	show1:function(){
		var show2=new Button(this.body,10,TAG_SHOW6,"#show5.png",this.callback,this); 
		show2.setPosition(cc.p(this.body.width*2.5,this.body.height*0.55));
		show2.setOpacity(0);
		var fadein=cc.fadeIn(0.1);
		var fadeout=cc.fadeOut(0.1);
		show2.runAction(cc.sequence(fadein,cc.delayTime(1),fadeout));
	},
	upFilm:function(){
		var fadein=cc.fadeIn(0.1);
		var film=this.body.getChildByTag(TAG_FILM2);
		var move=cc.moveBy(1,cc.p(0, this.body.height*0.65));
		film.runAction(cc.sequence(fadein,move));
	},
	rotateBody:function(){
		var rotate=cc.rotateBy(1,5);
		this.body.runAction(rotate);
	},
	rotateBack:function(){
		var rotate=cc.rotateBy(1,-5);
		this.body.runAction(rotate);
	},
	showWater:function(){
		var water=new Button(this.body,10,TAG_WATER,"#water.png",this.callback,this);
		water.setPosition(cc.p(this.body.width*0.4,0));
		water.runAction(cc.sequence(cc.moveBy(1,cc.p(0,-60)),cc.callFunc(function() {
			if(water.getPositionY()<this.body.height-60){
				water.removeFromParent();
				this.showWater();
			}
		},this)));
	},
	callback:function(p){
		var func=cc.callFunc(function() {
			gg.flow.next();
		}, this);
		var action=gg.flow.flow.action;
		switch (p.getTag()) {
		case TAG_BURET:
			var ber=cc.bezierBy(1, [cc.p(-30,50),cc.p(-335,180),cc.p(-335,115)]);
			p.runAction(cc.sequence(ber,cc.callFunc(function() {
				this.show();
			},this),func));
			break;
		case TAG_OPEN:
			var flask=ll.run.getChildByTag(TAG_FLASK_ALL);
			if(action==ACTION_DO1){
				p.runAction(cc.sequence(cc.callFunc(function() {
					this.showWater();
				},this),cc.delayTime(8),cc.callFunc(function() {
					flask.show2();
				},this),func));
			}else if(action==ACTION_DO2){
				var water=this.body.getChildByTag(TAG_WATER);
				p.runAction(cc.sequence(cc.callFunc(function() {
					this.show1();
					water.stopAllActions();
					water.setVisible(false);
				}, this),func));
			}
			break;
		default:
			break;
		}
	}
});